/**
 * Created by yuris on 28.01.15.
 */
package InterfaceObjects.OrdetProductWindow {
import feathers.controls.Button;
import feathers.controls.Label;
import feathers.display.Scale3Image;
import feathers.display.Scale3Image;
import feathers.text.BitmapFontTextFormat;

import starling.display.Image;

import starling.display.Sprite;
import starling.events.Touch;
import starling.events.TouchEvent;
import starling.events.TouchPhase;
import starling.filters.ColorMatrixFilter;

public class OrderProductItem extends Button {
    private var _bgSkin:Scale3Image;
    private var _bgSkinHover:Scale3Image;
    private var _productIcon:Image;
    private var _desriptionLabel:Label;
    private static var hoverFilter:ColorMatrixFilter;
    private var _id:String;
    public function OrderProductItem(id:String,productIconName:String, description:String) {
        super();
        this._id = id;
        this._bgSkin = new Scale3Image(GraphicFactory.getScale3Textures("Interface/Skins/bottom_panel_item_skin"));
        this._bgSkin.useSeparateBatch = false;
        this._bgSkin.width = 250;
        //this._bgSkin.alignPivot();
        this.defaultSkin = this._bgSkin;
        //addChild(this._bgSkin);

        if(hoverFilter == null){
            hoverFilter =  new ColorMatrixFilter();
            hoverFilter.adjustBrightness(0.1);
        }
        this._bgSkinHover = new Scale3Image(GraphicFactory.getScale3Textures("Interface/Skins/bottom_panel_item_skin"));
        this._bgSkinHover.filter = hoverFilter;
        this.hoverSkin = this._bgSkinHover;


        this._productIcon = GraphicFactory.getImageByName(productIconName);
        this._productIcon.alignPivot();
        this._productIcon.x = 45//-_bgSkin.width/2 + 45;
        this._productIcon.y = this._bgSkin.height/2;
        this._productIcon.touchable = false;
        addChild(this._productIcon);

        this._desriptionLabel = new Label();
        this._desriptionLabel.text = description;
        this._desriptionLabel.textRendererProperties.useSeparateBatch = false; //use separate if text color will change
        this._desriptionLabel.textRendererProperties.textFormat = new BitmapFontTextFormat("ComicDB_Dark",14)//, 0x333333);//color change causes extra Draw Call
        this._desriptionLabel.x = _bgSkin.width/2 - 30//- 40;
        this._desriptionLabel.y = 5//- 40;
        this._desriptionLabel.touchable = false;
        addChild(this._desriptionLabel);


        this.alignPivot()

        //this.addEventListener(TouchEvent.TOUCH, HANDLER_touch);

    }


    public function get id():String {
        return _id;
    }
}
}
